import pymongo
import csv
def export_csv() :
    client = pymongo.MongoClient("mongodb://localhost:27017/")
    db = client["ACM_MEMBER"]
    collection = db["TEAM_INFORMATION"]

    with open("../../../data/inner/export_file.csv", "w", newline="" , encoding="utf-8") as f :
        writer = csv.writer(f)
        writer.writerow(['学号','姓名','牛客账号','洛谷账号','codeforces账号','atcoder账号','vjudge账号','pta账号','密码','性别','年级','所属学院','专业'])
        for information in collection.find() :
            information.pop("_id")
            writer.writerow([information["student_id"], information["name"], information["nowcoder_id"], information["luogu_id"], information["codeforces_id"], information["atcoder_id"], information["vjudge_id"], information["pta_id"], information["mima"], information["sex"], information["grade"], information["college"], information["major"]])

    client.close()
if __name__ == '__main__' :
    export_csv()